home *** CD-ROM | disk | FTP | other *** search
- Path: sci.kun.nl!usenet
- From: Marian Hellema <marian@atcmp.nl>
- Newsgroups: comp.lang.c++
- Subject: Re: Q. only for ostrstream experts!!!
- Date: 8 Feb 1996 12:02:24 GMT
- Organization: AT Computing, Nijmegen, the Netherlands
- Message-ID: <4fcoog$6q6@wn1.sci.kun.nl>
- References: <4fab9d$1rp@fsuj01.rz.uni-jena.de>
- NNTP-Posting-Host: atcmpg.atcmp.kun.nl
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
- X-URL: news:4fab9d$1rp@fsuj01.rz.uni-jena.de
-
- mkt@isun04.inf.uni-jena.de (Tilo Koerbs) wrote:
- >
- >Consider:
- > ostrstream buf(); // dynamic buffer
- > buf << "something" << ends;
- > char *p = buf.str(); // freeze buffer and return a pointer to it
- >
- >Now: How do I delete the pointer p, using 'delete' or using 'delete[]'?
- >
-
- According to the april draft working paper for the ISO/ANSI
- standardization, ostrstream uses new[] to allocate memory (unless
- you supply it's strstreambuf with a different allocationfunction, which
- in this example is not the case).
- So you should use delete [] p to free it.
-
- [ By the way, the declaration of buf should be:
- ostrstream buf; ]
-
- Marian
- --
- ----------------------------------------------------------------------
- Marian Hellema AT Computing, UNIX training and consultancy
- email: marian@atcmp.nl P.O. Box 1428, 6501 BK Nijmegen
- phone: +31 24 3527225 the Netherlands
-
-